<?php
/**
 *  学员认证(学员登录|修改密码|注册?)
 */
namespace Steam\Auth;
use Aitifen\Library\Common\ApiClient;
use Steam\Common\Agency;

class UserAuth
{

    /**
     * 用户登录认证
     */
    public static function getToken($data){

        $userName = isset($data['userName']) ? trim($data['userName']) : '';        //用户名
        $passWord = isset($data['passWord']) ? trim($data['passWord']) : '';        //密码
        $agencyId = isset($data['agencyId']) ? trim($data['agencyId']) :'';         //机构id
        $platformName = isset($data['platformName']) ? trim($data['platformName']) : ''; //平台名称

        //账号
        if(!$userName){
            throw new \Exception('用户名不能为空!');
        }
        //密码
        if(!$passWord){
            throw new \Exception('密码不能为空!');
        }
        //平台名称
        if(!$platformName){
            throw new \Exception('平台名称不能为空!');
        }
        //获取平台信息
        $platformInfo = Agency::getPlatformInfo(['platformName'=>$platformName]);
        if(empty($platformInfo)){
            throw new \Exception('平台信息为空！');
        }
        //调用校管员工认证
        $data = ApiClient::syncGetResult($platformInfo['platform_key'],'getEmployeeToken',time(),['userName'=>$userName,'passWord'=>$passWord,'agencyId'=>$agencyId]);
        echo "<pre>";print_r($data);die;
        return $data;

    }

}